$(function(){
    showDetail();
});

var cur={
    page:{
        pageNo:1,
        pageSize:15,
    }
}


function showDetail() {
        $("#t1").addClass("tablab");
        $("#t2").removeClass("tablab");
        var id = $("#id").val();
        $.ajax({
            url: ctxPath+"/party/meeting/detailMeeting/" + id,
            type: 'GET',
            dataType: "html",
            success: function (d) {
                console.log(d);
                $("#content").html(d);
            },
            error: function () {
                alert("异常！");
            }
        });
}

function showSign() {
    $("#t2").addClass("tablab");
    $("#t1").removeClass("tablab");
    var id = $("#id").val();
    $.ajax({
        url: ctxPath+"/party/meeting/detailSign/" + id,
        type: 'GET',
        dataType: "html",
        success: function (d) {
            $("#content").html(d);
            getList(cur.page.pageNo,cur.page.pageSize);
        },
        error: function () {
            alert("异常！");
        }
    });
}

function getList(pageNo, pageSize) {
    var id = $("#id").val();
    $.ajax({
        url: ctxPath+"/party/exam/showResult",
        type: 'POST',
        data: {pageNo: pageNo, pageSize: pageSize,meetingId:id},
        success: function (d) {
            if (d.data != null) {
                var html = "";
                $.each(d.data.dataList, function (i, item) {
                    html += toHtml(item);
                })
                $("#list_result").html(html);
                getPage(d.data.pages, d.data.total);
            }

        }
    });
}

//分页
function getPage(pageCount, totalCount) {
    kkpager.total = pageCount;//总页码
    kkpager.totalRecords = totalCount;//总条数
    kkpager.generPageHtml({
        pno: 0,
        mode: 'click',//默认值是link，可选link或者click
        click: function (n) {
            getList(n, 15);
            cur.page.pageNo=n;
            this.selectPage(n);
            return false;
        }
    });
}

function toHtml(data) {
    console.log(data);
    var updateTime = '';
    if(data.updateTime != null && data.updateTime != ''){
        updateTime = new Date(data.updateTime).Format("yyyy-MM-dd hh:mm");
    }

    var name = ""
    if(data.sysUser != null && data.sysUser.nickname != null){
        name = data.sysUser.nickname;
    }

    return '<tr>'
        + '<td>'
        + '<img src="' + ctxPath+'/'+data.headImage + '" width="100px;">&nbsp;&nbsp;&nbsp;&nbsp;'
        + '</td>'
        + '<td class="text-center">'
        + name + '<br>' + updateTime
        + '</td>'
        + '</tr>';
}